<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>std::bind</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../../common/favicon.ico">
<link rel="stylesheet" href="../../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/utility/functional/bind","wgTitle":"cpp/utility/functional/bind","wgCurRevisionId":63944,"wgArticleId":4070,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/utility/functional/bind","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_utility_functional_bind skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::</span>bind</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../../cpp.html" title="cpp">cpp</a>‎ | <a href="../../utility.html" title="cpp/utility">utility</a>‎ | <a href="../functional.html" title="cpp/utility/functional">functional</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../../language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../utility.html" title="cpp/utility">工具库</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../../types.html" title="cpp/types">类型支持</a>（基本类型、 RTTI 、类型特性）</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../memory.html" title="cpp/memory">动态内存管理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../error.html" title="cpp/error">错误处理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../program.html" title="cpp/utility/program">程序工具</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../variadic.html" title="cpp/utility/variadic">变参数函数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../feature_test.html" title="cpp/utility/feature test">库特性测试宏</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../../chrono.html" title="cpp/chrono">日期和时间</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../functional.html" title="cpp/utility/functional">函数对象</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../format.html" title="cpp/utility/format"> 格式化库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../initializer_list.html" title="cpp/utility/initializer list"><span class="t-lines"><span>initializer_list</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../source_location.html" title="cpp/utility/source location"><span class="t-lines"><span>source_location</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../bitset.html" title="cpp/utility/bitset"><span class="t-lines"><span>bitset</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../hash.html" title="cpp/utility/hash"><span class="t-lines"><span>hash</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../integer_sequence.html" title="cpp/utility/integer sequence"><span class="t-lines"><span>integer_sequence</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 关系运算符 <span class="t-mark-rev t-deprecated-cxx20">(C++20 中弃用)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../rel_ops/operator_cmp.html" title="cpp/utility/rel ops/operator cmp"><span class="t-lines"><span>rel_ops::operator!=</span><span>rel_ops::operator&gt;</span><span>rel_ops::operator&lt;=</span><span>rel_ops::operator&gt;=</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 比较 <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr><tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/three_way_comparable.html" title="cpp/utility/compare/three way comparable"><span class="t-lines"><span>three_way_comparable</span><span>three_way_comparable_with</span></span></a></div></div></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/strong_ordering.html" title="cpp/utility/compare/strong ordering"><span class="t-lines"><span>strong_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/weak_ordering.html" title="cpp/utility/compare/weak ordering"><span class="t-lines"><span>weak_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/partial_ordering.html" title="cpp/utility/compare/partial ordering"><span class="t-lines"><span>partial_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/common_comparison_category.html" title="cpp/utility/compare/common comparison category"><span class="t-lines"><span>common_comparison_category</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/compare_three_way_result.html" title="cpp/utility/compare/compare three way result"><span class="t-lines"><span>compare_three_way_result</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/compare_three_way.html" title="cpp/utility/compare/compare three way"><span class="t-lines"><span>compare_three_way</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/strong_order.html" title="cpp/utility/compare/strong order"><span class="t-lines"><span>strong_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/weak_order.html" title="cpp/utility/compare/weak order"><span class="t-lines"><span>weak_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/partial_order.html" title="cpp/utility/compare/partial order"><span class="t-lines"><span>partial_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/compare_strong_order_fallback.html" title="cpp/utility/compare/compare strong order fallback"><span class="t-lines"><span>compare_strong_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/compare_weak_order_fallback.html" title="cpp/utility/compare/compare weak order fallback"><span class="t-lines"><span>compare_weak_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/compare_partial_order_fallback.html" title="cpp/utility/compare/compare partial order fallback"><span class="t-lines"><span>compare_partial_order_fallback</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../compare/named_comparison_functions.html" title="cpp/utility/compare/named comparison functions"><span class="t-lines"><span>is_eq</span><span>is_neq</span><span>is_lt</span><span>is_lteq</span><span>is_gt</span><span>is_gteq</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 共用词汇类型</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../pair.html" title="cpp/utility/pair"><span class="t-lines"><span>pair</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../tuple.html" title="cpp/utility/tuple"><span class="t-lines"><span>tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../apply.html" title="cpp/utility/apply"><span class="t-lines"><span>apply</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../make_from_tuple.html" title="cpp/utility/make from tuple"><span class="t-lines"><span>make_from_tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../optional.html" title="cpp/utility/optional"><span class="t-lines"><span>optional</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../any.html" title="cpp/utility/any"><span class="t-lines"><span>any</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../variant.html" title="cpp/utility/variant"><span class="t-lines"><span>variant</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> swap 、 forward 与 move</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../../algorithm/swap.html" title="cpp/algorithm/swap"><span class="t-lines"><span>swap</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../exchange.html" title="cpp/utility/exchange"><span class="t-lines"><span>exchange</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../forward.html" title="cpp/utility/forward"><span class="t-lines"><span>forward</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../move.html" title="cpp/utility/move"><span class="t-lines"><span>move</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../move_if_noexcept.html" title="cpp/utility/move if noexcept"><span class="t-lines"><span>move_if_noexcept</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 初等字符串转换</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../to_chars.html" title="cpp/utility/to chars"><span class="t-lines"><span>to_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../from_chars.html" title="cpp/utility/from chars"><span class="t-lines"><span>from_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../chars_format.html" title="cpp/utility/chars format"><span class="t-lines"><span>chars_format</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 类型运算</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../declval.html" title="cpp/utility/declval"><span class="t-lines"><span>declval</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../as_const.html" title="cpp/utility/as const"><span class="t-lines"><span>as_const</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../launder.html" title="cpp/utility/launder"><span class="t-lines"><span>launder</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../functional.html" title="cpp/utility/functional">函数对象</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 函数包装 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="function.html" title="cpp/utility/functional/function"><span class="t-lines"><span>function</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="mem_fn.html" title="cpp/utility/functional/mem fn"><span class="t-lines"><span>mem_fn</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bad_function_call.html" title="cpp/utility/functional/bad function call"><span class="t-lines"><span>bad_function_call</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 部分函数应用 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>bind</span></span></strong></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bind_front.html" title="cpp/utility/functional/bind front"><span class="t-lines"><span>bind_front</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="is_bind_expression.html" title="cpp/utility/functional/is bind expression"><span class="t-lines"><span>is_bind_expression</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="is_placeholder.html" title="cpp/utility/functional/is placeholder"><span class="t-lines"><span>is_placeholder</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="placeholders.html" title="cpp/utility/functional/placeholders"><span class="t-lines"><span>_1, _2, _3, ...</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 函数调用 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="invoke.html" title="cpp/utility/functional/invoke"><span class="t-lines"><span>invoke</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 恒等函数对象</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="identity.html" title="cpp/utility/functional/identity"><span class="t-lines"><span>identity</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 引用包装 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="reference_wrapper.html" title="cpp/utility/functional/reference wrapper"><span class="t-lines"><span>reference_wrapper</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ref.html" title="cpp/utility/functional/ref"><span class="t-lines"><span>ref</span><span>cref</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="unwrap_reference.html" title="cpp/utility/functional/unwrap reference"><span class="t-lines"><span>unwrap_reference</span><span>unwrap_ref_decay</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 运算符包装 </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="plus.html" title="cpp/utility/functional/plus"><span class="t-lines"><span>plus</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="minus.html" title="cpp/utility/functional/minus"><span class="t-lines"><span>minus</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="negate.html" title="cpp/utility/functional/negate"><span class="t-lines"><span>negate</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="multiplies.html" title="cpp/utility/functional/multiplies"><span class="t-lines"><span>multiplies</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="divides.html" title="cpp/utility/functional/divides"><span class="t-lines"><span>divides</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="modulus.html" title="cpp/utility/functional/modulus"><span class="t-lines"><span>modulus</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="logical_and.html" title="cpp/utility/functional/logical and"><span class="t-lines"><span>logical_and</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="logical_or.html" title="cpp/utility/functional/logical or"><span class="t-lines"><span>logical_or</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="logical_not.html" title="cpp/utility/functional/logical not"><span class="t-lines"><span>logical_not</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="equal_to.html" title="cpp/utility/functional/equal to"><span class="t-lines"><span>equal_to</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="not_equal_to.html" title="cpp/utility/functional/not equal to"><span class="t-lines"><span>not_equal_to</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="greater.html" title="cpp/utility/functional/greater"><span class="t-lines"><span>greater</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="less.html" title="cpp/utility/functional/less"><span class="t-lines"><span>less</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="greater_equal.html" title="cpp/utility/functional/greater equal"><span class="t-lines"><span>greater_equal</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="less_equal.html" title="cpp/utility/functional/less equal"><span class="t-lines"><span>less_equal</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_and.html" title="cpp/utility/functional/bit and"><span class="t-lines"><span>bit_and</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_or.html" title="cpp/utility/functional/bit or"><span class="t-lines"><span>bit_or</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_xor.html" title="cpp/utility/functional/bit xor"><span class="t-lines"><span>bit_xor</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bit_not.html" title="cpp/utility/functional/bit not"><span class="t-lines"><span>bit_not</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 取反器 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="not_fn.html" title="cpp/utility/functional/not fn"><span class="t-lines"><span>not_fn</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 搜索器 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="default_searcher.html" title="cpp/utility/functional/default searcher"><span class="t-lines"><span>default_searcher</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="boyer_moore_searcher.html" title="cpp/utility/functional/boyer moore searcher"><span class="t-lines"><span>boyer_moore_searcher</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="boyer_moore_horspool_searcher.html" title="cpp/utility/functional/boyer moore horspool searcher"><span class="t-lines"><span>boyer_moore_horspool_searcher</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 有制约的比较器</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/equal_to.html" title="cpp/utility/functional/ranges/equal to"><span class="t-lines"><span>ranges::equal_to</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/not_equal_to.html" title="cpp/utility/functional/ranges/not equal to"><span class="t-lines"><span>ranges::not_equal_to</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/greater.html" title="cpp/utility/functional/ranges/greater"><span class="t-lines"><span>ranges::greater</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/less.html" title="cpp/utility/functional/ranges/less"><span class="t-lines"><span>ranges::less</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/greater_equal.html" title="cpp/utility/functional/ranges/greater equal"><span class="t-lines"><span>ranges::greater_equal</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/less_equal.html" title="cpp/utility/functional/ranges/less equal"><span class="t-lines"><span>ranges::less_equal</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 旧绑定器与适配器 </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="unary_function.html" title="cpp/utility/functional/unary function"><span class="t-lines"><span>unary_function</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="binary_function.html" title="cpp/utility/functional/binary function"><span class="t-lines"><span>binary_function</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ptr_fun.html" title="cpp/utility/functional/ptr fun"><span class="t-lines"><span>ptr_fun</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="pointer_to_unary_function.html" title="cpp/utility/functional/pointer to unary function"><span class="t-lines"><span>pointer_to_unary_function</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="pointer_to_binary_function.html" title="cpp/utility/functional/pointer to binary function"><span class="t-lines"><span>pointer_to_binary_function</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/utility/functional/mem_fun&amp;action=edit&amp;redlink=1" class="new" title="cpp/utility/functional/mem fun（页面不存在）"><span class="t-lines"><span>mem_fun</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="mem_fun_t.html" title="cpp/utility/functional/mem fun t"><span class="t-lines"><span>mem_fun_t</span><span>mem_fun1_t</span><span>const_mem_fun_t</span><span>const_mem_fun1_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="not1.html" title="cpp/utility/functional/not1"><span class="t-lines"><span>not1</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="not2.html" title="cpp/utility/functional/not2"><span class="t-lines"><span>not2</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/utility/functional/binder12&amp;action=edit&amp;redlink=1" class="new" title="cpp/utility/functional/binder12（页面不存在）"><span class="t-lines"><span>binder1st</span><span>binder2nd</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bind12.html" title="cpp/utility/functional/bind12"><span class="t-lines"><span>bind1st</span><span>bind2nd</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/utility/functional/mem_fun_ref&amp;action=edit&amp;redlink=1" class="new" title="cpp/utility/functional/mem fun ref（页面不存在）"><span class="t-lines"><span>mem_fun_ref</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="mem_fun_ref_t.html" title="cpp/utility/functional/mem fun ref t"><span class="t-lines"><span>mem_fun_ref_t</span><span>mem_fun1_ref_t</span><span>const_mem_fun_ref_t</span><span>const_mem_fun1_ref_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span><span><span class="t-mark-rev t-until-cxx17">(C++17 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="unary_negate.html" title="cpp/utility/functional/unary negate"><span class="t-lines"><span>unary_negate</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="binary_negate.html" title="cpp/utility/functional/binary negate"><span class="t-lines"><span>binary_negate</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span></div></div></td></tr>
</table></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>定义于头文件 <code><a href="../../header/functional.html" title="cpp/header/functional">&lt;functional&gt;</a></code>
 </div></td>
<td></td>
<td></td>
</tr>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num"><tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(1)</td>
<td></td>
</tr>
<tr class="t-dcl t-since-cxx11 t-until-cxx20">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> F, <span class="kw1">class</span>... <span class="me1">Args</span> <span class="sy1">&gt;</span><br>
<span class="coMULTI">/*unspecified*/</span> bind<span class="br0">(</span> F<span class="sy3">&amp;&amp;</span> f, Args<span class="sy3">&amp;&amp;</span>... <span class="me1">args</span> <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx11">(C++11 起)</span> <br><span class="t-mark-rev t-until-cxx20">(C++20 前)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx20">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> F, <span class="kw1">class</span>... <span class="me1">Args</span> <span class="sy1">&gt;</span><br>
<span class="kw4">constexpr</span> <span class="coMULTI">/*unspecified*/</span> bind<span class="br0">(</span> F<span class="sy3">&amp;&amp;</span> f, Args<span class="sy3">&amp;&amp;</span>... <span class="me1">args</span> <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span> </td>
</tr>
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num"><tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(2)</td>
<td></td>
</tr>
<tr class="t-dcl t-since-cxx11 t-until-cxx20">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> R, <span class="kw1">class</span> F, <span class="kw1">class</span>... <span class="me1">Args</span> <span class="sy1">&gt;</span><br>
<span class="coMULTI">/*unspecified*/</span> bind<span class="br0">(</span> F<span class="sy3">&amp;&amp;</span> f, Args<span class="sy3">&amp;&amp;</span>... <span class="me1">args</span> <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx11">(C++11 起)</span> <br><span class="t-mark-rev t-until-cxx20">(C++20 前)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx20">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> R, <span class="kw1">class</span> F, <span class="kw1">class</span>... <span class="me1">Args</span> <span class="sy1">&gt;</span><br>
<span class="kw4">constexpr</span> <span class="coMULTI">/*unspecified*/</span> bind<span class="br0">(</span> F<span class="sy3">&amp;&amp;</span> f, Args<span class="sy3">&amp;&amp;</span>... <span class="me1">args</span> <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span> </td>
</tr>
</tbody><tbody>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>函数模板 <code>bind</code> 生成 <code>f</code> 的转发调用包装器。调用此包装器等价于以一些绑定到 <code>args</code> 的参数调用 <code>f</code> 。
</p>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">参数</span></h3>
<table class="t-par-begin">


<tr class="t-par">
<td>  f
</td>
<td> -
</td>
<td> <a href="../../named_req/Callable.html" title="cpp/named req/Callable"><i>可调用</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(Callable)</span> </a>对象（函数对象、指向函数指针、到函数引用、指向成员函数指针或指向数据成员指针）
</td></tr>
<tr class="t-par">
<td>  args
</td>
<td> -
</td>
<td> 要绑定的参数列表，未绑定参数为命名空间 <code>std::placeholders</code> 的占位符 <code>_1, _2, _3...</code> 所替换
</td></tr></table>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">返回值</span></h3>
<p>未指定类型 <code>T</code> 的函数对象，满足 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="is_bind_expression.html"><span class="kw1052">std::<span class="me2">is_bind_expression</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">value</span> <span class="sy1">==</span> <span class="kw2">true</span></span></span> 。它有下列属性：
</p>
<div class="t-member">
<h2> <span class="mw-headline" id="std::bind_.E8.BF.94.E5.9B.9E.E7.B1.BB.E5.9E.8B"> <span style="font-size:0.7em; line-height:130%">std::bind</span> <i>返回类型</i> </span></h2>
<h4> <span class="mw-headline" id=".E6.88.90.E5.91.98.E5.AF.B9.E8.B1.A1">成员对象</span></h4>
<p><code>std::bind</code> 的返回类型保有从 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>F<span class="sy1">&gt;</span><span class="br0">(</span>f<span class="br0">)</span></span></span> 构造的 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../types/decay.html"><span class="kw628">std::<span class="me2">decay</span></span></a><span class="sy1">&lt;</span>F<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">type</span></span></span> 类型成员对象，和对于每个 <code>args...</code> 类型为 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../types/decay.html"><span class="kw628">std::<span class="me2">decay</span></span></a><span class="sy1">&lt;</span>Arg_i<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">type</span></span></span> 的各一个对象，类似地从 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>Arg_i<span class="sy1">&gt;</span><span class="br0">(</span>arg_i<span class="br0">)</span></span></span> 构造。
</p>
<h4> <span class="mw-headline" id=".E6.9E.84.E9.80.A0.E5.87.BD.E6.95.B0">构造函数</span></h4>
<p>若 <code>std::bind</code> 的返回类型的所有成员类型（说明如上）为<a href="../../named_req/CopyConstructible.html" title="cpp/named req/CopyConstructible"><i>可复制构造</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(CopyConstructible)</span> </a>，则它为可复制构造 (CopyConstructible) ，否则为<a href="../../named_req/MoveConstructible.html" title="cpp/named req/MoveConstructible"><i>可移动构造</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(MoveConstructible)</span> </a>。类型定义下列成员：
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-until-cxx20"><td>
<h4> <span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB.E5.9E.8B_result_type">成员类型 <code>result_type</code></span></h4>
<p>1) <span class="t-mark-rev t-deprecated-cxx17">(C++17 中弃用)</span> 若 <code>F</code> 是指向函数或指向成员函数指针，则 <code>result_type</code> 是 <code>F</code> 的返回类型。若 <code>F</code> 是有嵌套 typedef <code>result_type</code> 的类类型，则 <code>result_type</code> 是 <code>F::result_type</code> 。否则不定义 <code>result_type</code> 。
</p><p>2) <span class="t-mark-rev t-deprecated-cxx17">(C++17 中弃用)</span> <code>result_type</code> 准确地为 <code>R</code> 。
</p>
</td>
<td><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></td></tr>
</table>
<h4> <span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0_operator.28.29">成员函数 <code>operator()</code></span></h4>
<p>给定从先前到 <code>bind</code> 调用获得的对象 <code>g</code> ，从函数调用表达式 <span class="t-c"><span class="mw-geshi cpp source-cpp">g<span class="br0">(</span>u1, u2, ... <span class="me1">uM</span><span class="br0">)</span></span></span> 调用它时，发生被存储对象的调用，如同以 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="invoke.html"><span class="kw1057">std::<span class="me2">invoke</span></span></a><span class="br0">(</span>fd, <a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>V1<span class="sy1">&gt;</span><span class="br0">(</span>v1<span class="br0">)</span>, <a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>V2<span class="sy1">&gt;</span><span class="br0">(</span>v2<span class="br0">)</span>, ..., <a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>VN<span class="sy1">&gt;</span><span class="br0">(</span>vN<span class="br0">)</span><span class="br0">)</span></span></span> ，其中 <code>fd</code> 是 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../types/decay.html"><span class="kw629">std::<span class="me2">decay_t</span></span></a><span class="sy1">&lt;</span>F<span class="sy1">&gt;</span></span></span> 类型值，受绑定 <code>v1, v2, ..., vN</code> 参数的值和类型按以下方式确定。
</p>
<ul><li> 若存储的参数 <code>arg</code> 拥有类型 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="reference_wrapper.html"><span class="kw1067">std::<span class="me2">reference_wrapper</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span></span></span> （例如，在起始的到 <code>bind</code> 调用中使用了 <span class="t-lc"><a href="ref.html" title="cpp/utility/functional/ref">std::ref</a></span> 或 <span class="t-lc"><a href="ref.html" title="cpp/utility/functional/ref">std::cref</a></span> ），则上述 <code>std::invoke</code> 调用中的 <code>vn</code> 是 <code>arg.get()</code> 且同一调用中的类型 <code>Vn</code> 是 <code>T&amp;</code> ：存储的参数按引用传递进入被调用的函数对象。
</li><li> 若存储的参数 <code>arg</code> 拥有类型 <code>T</code> 并满足 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="is_bind_expression.html"><span class="kw1052">std::<span class="me2">is_bind_expression</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">value</span> <span class="sy1">==</span> <span class="kw2">true</span></span></span> （例如，直接传递到起始的对 <code>bind</code> 调用的另一 <code>bind</code> 表达式），则 <code>bind</code> 进行函数组合：不是传递该 bind 子表达式将返回的函数对象，而是饥渴地调用该子表达式，并将其返回值传递给外层可调用对象。若 bind 子表达式拥有任何占位符参数，则将它们与外层 bind 共享（从 <code>u1, u2, ...</code> 中选出）。特别是，上述 <code>std::invoke</code> 调用中的参数 <code>vn</code> 是 <code>arg(std::forward&lt;Uj&gt;(uj)...)</code> 而同一调用中的类型 <code>Vn</code> 是 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../types/result_of.html"><span class="kw640">std::<span class="me2">result_of_t</span></span></a><span class="sy1">&lt;</span>T cv <span class="sy3">&amp;</span><span class="br0">(</span>Uj<span class="sy3">&amp;&amp;</span>...<span class="br0">)</span><span class="sy1">&gt;</span><span class="sy3">&amp;&amp;</span></span></span> （ cv 限定与 <code>g</code> 的相同）。
</li><li> 若存储的参数 <code>arg</code> 拥有类型 <code>T</code> 并满足 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="is_placeholder.html"><span class="kw1053">std::<span class="me2">is_placeholder</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">value</span> <span class="sy3">!</span><span class="sy1">=</span> <span class="nu0">0</span></span></span> （表示以如 <code>std::placeholders::_1, _2, _3, ...</code> 的占位符为到 <code>bind</code> 初始调用的参数），则将占位符所指示的参数（ <code>_1</code> 的 <code>u1</code> 、 <code>_2</code> 的 <code>u2</code> 等）传递给可调用对象：上述 <code>std::invoke</code> 调用中的参数 <code>vn</code> 是 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>Uj<span class="sy1">&gt;</span><span class="br0">(</span>uj<span class="br0">)</span></span></span> 而同一调用中对应类型 <code>Vn</code> 是 <span class="t-c"><span class="mw-geshi cpp source-cpp">Uj<span class="sy3">&amp;&amp;</span></span></span> 。
</li><li> 否则，普通的存储参数 <code>arg</code> 作为左值参数传递给：上述 <code>std::invoke</code> 调用中的参数 <code>vn</code> 单纯地是 <code>arg</code> 且对应类型 <code>Vn</code> 是 <code>T cv &amp;</code> ，其中 cv 是与 <code>g</code> 相同的 cv 限定。
</li></ul>
<p>若提供于到 <code>g()</code> 调用的一些参数不匹配存储于 <code>g</code> 的任何占位符，则求值并忽略未使用的参数。
</p><p>若 <code>g</code> 为 volatile 限定（即其 cv 限定符是 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">volatile</span></span></span> 或 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">const</span> <span class="kw4">volatile</span></span></span> ），则行为未定义。
</p>
</div>
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8">异常</span></h3>
<p>仅若从 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>F<span class="sy1">&gt;</span><span class="br0">(</span>f<span class="br0">)</span></span></span> 构造 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../types/decay.html"><span class="kw628">std::<span class="me2">decay</span></span></a><span class="sy1">&lt;</span>F<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">type</span></span></span> 抛出，或从 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../forward.html"><span class="kw1116">std::<span class="me2">forward</span></span></a><span class="sy1">&lt;</span>Arg_i<span class="sy1">&gt;</span><span class="br0">(</span>arg_i<span class="br0">)</span></span></span> 构造对应的任何 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../../types/decay.html"><span class="kw628">std::<span class="me2">decay</span></span></a><span class="sy1">&lt;</span>Arg_i<span class="sy1">&gt;</span><span class="sy4">::</span><span class="me2">type</span></span></span> 抛出才抛出异常，其中 <code>Arg_i</code> 是 <code>Args... args</code> 中第 i 个类型，而 <code>arg_i</code> 是第 i 个参数。
</p>
<h3><span class="mw-headline" id=".E6.B3.A8.E8.A7.A3">注解</span></h3>
<p>如<a href="../../named_req/Callable.html" title="cpp/named req/Callable"><i>可调用</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(Callable)</span> </a>中描述，调用指向非静态成员函数指针或指向非静态数据成员指针时，首参数必须是引用或指针（可以包含智能指针，如 <span class="t-lc"><a href="../../memory/shared_ptr.html" title="cpp/memory/shared ptr">std::shared_ptr</a></span> 与 <span class="t-lc"><a href="../../memory/unique_ptr.html" title="cpp/memory/unique ptr">std::unique_ptr</a></span>），指向将访问其成员的对象。
</p><p>到 bind 的参数被复制或移动，而且决不按引用传递，除非包装于 <span class="t-lc"><a href="ref.html" title="cpp/utility/functional/ref">std::ref</a></span> 或 <span class="t-lc"><a href="ref.html" title="cpp/utility/functional/ref">std::cref</a></span> 。
</p><p>允许同一 bind 表达式中的多重占位符（例如多个 <code>_1</code> ），但结果仅若对应参数（ <code>u1</code> ）是左值或不可移动右值才良好定义。
</p>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;random&gt;</span>
<span class="co2">#include &lt;iostream&gt;</span>
<span class="co2">#include &lt;memory&gt;</span>
<span class="co2">#include &lt;functional&gt;</span>
 
<span class="kw4">void</span> f<span class="br0">(</span><span class="kw4">int</span> n1, <span class="kw4">int</span> n2, <span class="kw4">int</span> n3, <span class="kw4">const</span> <span class="kw4">int</span><span class="sy3">&amp;</span> n4, <span class="kw4">int</span> n5<span class="br0">)</span>
<span class="br0">{</span>
    <a href="../../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> n1 <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> n2 <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> n3 <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> n4 <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> n5 <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
<span class="br0">}</span>
 
<span class="kw4">int</span> g<span class="br0">(</span><span class="kw4">int</span> n1<span class="br0">)</span>
<span class="br0">{</span>
    <span class="kw1">return</span> n1<span class="sy4">;</span>
<span class="br0">}</span>
 
<span class="kw1">struct</span> Foo <span class="br0">{</span>
    <span class="kw4">void</span> print_sum<span class="br0">(</span><span class="kw4">int</span> n1, <span class="kw4">int</span> n2<span class="br0">)</span>
    <span class="br0">{</span>
        <a href="../../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> n1<span class="sy2">+</span>n2 <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    <span class="br0">}</span>
    <span class="kw4">int</span> data <span class="sy1">=</span> <span class="nu0">10</span><span class="sy4">;</span>
<span class="br0">}</span><span class="sy4">;</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    <span class="kw1">using</span> <span class="kw1">namespace</span> <a href="placeholders.html"><span class="kw1060">std::<span class="me2">placeholders</span></span></a><span class="sy4">;</span>  <span class="co1">// 对于 _1, _2, _3...</span>
 
    <span class="co1">// 演示参数重排序和按引用传递</span>
    <span class="kw4">int</span> n <span class="sy1">=</span> <span class="nu0">7</span><span class="sy4">;</span>
    <span class="co1">// （ _1 与 _2 来自 std::placeholders ，并表示将来会传递给 f1 的参数）</span>
    <span class="kw4">auto</span> f1 <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">bind</span><span class="br0">(</span>f, _2, <span class="nu0">42</span>, _1, <a href="ref.html"><span class="kw1069">std::<span class="me2">cref</span></span></a><span class="br0">(</span>n<span class="br0">)</span>, n<span class="br0">)</span><span class="sy4">;</span>
    n <span class="sy1">=</span> <span class="nu0">10</span><span class="sy4">;</span>
    f1<span class="br0">(</span><span class="nu0">1</span>, <span class="nu0">2</span>, <span class="nu0">1001</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// 1 为 _1 所绑定， 2 为 _2 所绑定，不使用 1001</span>
                    <span class="co1">// 进行到 f(2, 42, 1, n, 7) 的调用</span>
 
    <span class="co1">// 嵌套 bind 子表达式共享占位符</span>
    <span class="kw4">auto</span> f2 <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">bind</span><span class="br0">(</span>f, _3, std<span class="sy4">::</span><span class="me2">bind</span><span class="br0">(</span>g, _3<span class="br0">)</span>, _3, <span class="nu0">4</span>, <span class="nu0">5</span><span class="br0">)</span><span class="sy4">;</span>
    f2<span class="br0">(</span><span class="nu0">10</span>, <span class="nu0">11</span>, <span class="nu0">12</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// 进行到 f(12, g(12), 12, 4, 5); 的调用</span>
 
    <span class="co1">// 常见使用情况：以分布绑定 RNG</span>
    <a href="../../numeric/random.html"><span class="kw1495">std::<span class="me2">default_random_engine</span></span></a> e<span class="sy4">;</span>
    <a href="../../numeric/random/uniform_int_distribution.html"><span class="kw1501">std::<span class="me2">uniform_int_distribution</span></span></a><span class="sy1">&lt;&gt;</span> d<span class="br0">(</span><span class="nu0">0</span>, <span class="nu0">10</span><span class="br0">)</span><span class="sy4">;</span>
    <a href="function.html"><span class="kw1058">std::<span class="me2">function</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span><span class="br0">(</span><span class="br0">)</span><span class="sy1">&gt;</span> rnd <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">bind</span><span class="br0">(</span>d, e<span class="br0">)</span><span class="sy4">;</span> <span class="co1">// e 的一个副本存储于 rnd</span>
    <span class="kw1">for</span><span class="br0">(</span><span class="kw4">int</span> n<span class="sy1">=</span><span class="nu0">0</span><span class="sy4">;</span> n<span class="sy1">&lt;</span><span class="nu0">10</span><span class="sy4">;</span> <span class="sy2">++</span>n<span class="br0">)</span>
        <a href="../../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> rnd<span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span><span class="sy4">;</span>
    <a href="../../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
 
    <span class="co1">// 绑定指向成员函数指针</span>
    Foo foo<span class="sy4">;</span>
    <span class="kw4">auto</span> f3 <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">bind</span><span class="br0">(</span><span class="sy3">&amp;</span>Foo<span class="sy4">::</span><span class="me2">print_sum</span>, <span class="sy3">&amp;</span>foo, <span class="nu0">95</span>, _1<span class="br0">)</span><span class="sy4">;</span>
    f3<span class="br0">(</span><span class="nu0">5</span><span class="br0">)</span><span class="sy4">;</span>
 
    <span class="co1">// 绑定指向数据成员指针</span>
    <span class="kw4">auto</span> f4 <span class="sy1">=</span> std<span class="sy4">::</span><span class="me2">bind</span><span class="br0">(</span><span class="sy3">&amp;</span>Foo<span class="sy4">::</span><span class="me2">data</span>, _1<span class="br0">)</span><span class="sy4">;</span>
    <a href="../../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> f4<span class="br0">(</span>foo<span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
 
    <span class="co1">// 智能指针亦能用于调用被引用对象的成员</span>
    <a href="../../io/cout.html"><span class="kw1757">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> f4<span class="br0">(</span><a href="../../memory/shared_ptr/make_shared.html"><span class="kw736">std::<span class="me2">make_shared</span></span></a><span class="sy1">&lt;</span>Foo<span class="sy1">&gt;</span><span class="br0">(</span>foo<span class="br0">)</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span>
              <span class="sy1">&lt;&lt;</span> f4<span class="br0">(</span><a href="../../memory/unique_ptr/make_unique.html"><span class="kw735">std::<span class="me2">make_unique</span></span></a><span class="sy1">&lt;</span>Foo<span class="sy1">&gt;</span><span class="br0">(</span>foo<span class="br0">)</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">2 42 1 10 7
12 12 12 4 5
1 5 0 2 0 8 2 2 10 8
100
10
10
10</pre></div></div> 
</div>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="bind_front.html" title="cpp/utility/functional/bind front"> <span class="t-lines"><span>bind_front</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  按顺序绑定一定数量的参数到函数对象 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="placeholders.html" title="cpp/utility/functional/placeholders"> <span class="t-lines"><span>_1, _2, _3, _4, ...</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>   用作 <code>std::bind</code> 表达式中的未绑定实参的占位符  <br> <span class="t-mark">(常量)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="mem_fn.html" title="cpp/utility/functional/mem fn"> <span class="t-lines"><span>mem_fn</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  从成员指针创建出函数对象 <br> <span class="t-mark">(函数模板)</span> </td></tr>
</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 10083/1000000
Preprocessor generated node count: 15142/1000000
Post‐expand include size: 285552/2097152 bytes
Template argument size: 64256/2097152 bytes
Highest expansion depth: 20/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:4070-0!*!0!!zh!*!zh!* and timestamp 20200206144059 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/utility/functional/bind&amp;oldid=63944">https://zh.cppreference.com/mwiki/index.php?title=cpp/utility/functional/bind&amp;oldid=63944</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/utility/functional/bind">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2020年1月26日 (星期日) 00:42。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过56,123次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 2.347 secs. -->
	</body>
<!-- Cached 20200206144059 -->
</html>